/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sorting3;

/**
 *
 * @author Student
 */
public class Sorting3 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int arr[]= new int[10];
        int i;
        int j;
        int iMin;
        arr=initArray();
        print(arr);
        for(j=0;j<arr.length;j++)
        {
            iMin=j;
                    for(i=j;i<arr.length;i++)
                    {
                        if (arr[i]<arr[iMin])
                        {
                            iMin=i;
                        }
                    }
                    if(iMin!=j)
                    {
                        int placeholder;
                    placeholder = arr[iMin];
                    arr[iMin] = arr[j];
                    arr[j] = placeholder;
                    }
        }
        print(arr);
    }

    private static void print(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println("");
    }

    private static int[] initArray() {
        int arr[] = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100);
        }
        return arr;
    }
}
